package com.malty.mall.controller.ums;

import com.malty.mall.common.CommonResult;
import com.malty.mall.domain.dto.req.UmsResourceTypeParam;
import com.malty.mall.service.ums.IUmsResourceTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author malty
 */
@RestController
@Api(tags = "资源类型管理")
@RequestMapping("/resource/type")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class UmsResourceTypeController {
    private final IUmsResourceTypeService umsResourceTypeService;

    @PostMapping("/create")
    @ApiOperation("创建资源类型")
    public CommonResult<Boolean> createUmsResourceType(@Validated @RequestBody UmsResourceTypeParam umsResourceTypeParam) {
        return CommonResult.success(umsResourceTypeService.create(umsResourceTypeParam));
    }

    @GetMapping("/list")
    @ApiOperation("查询所有资源")
    public CommonResult<List<UmsResourceTypeParam>> listUmsResourceType() {
        return CommonResult.success(umsResourceTypeService.listAll());
    }
}
